/*
*    Author : heiden deng(dengjianquan@beyondcent.com)
*    2017/06/13
*    version 0.0.9
*    类型定义
*/

#ifndef HTSC_TYPES_H
#define HTSC_TYPES_H

#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif

#define HTSC_GRPC_LOCAL_HOST "127.0.0.1"
#define HTSC_GRPC_ANY_HOST   "0.0.0.0"

#define HTSC_GRPC_LB_TYPE_GRPCLB "grpclb"
#define HTSC_GRPC_LB_TYPE_PF "pick_first"
#define HTSC_GRPC_LB_TYPE_RR "round_robin"
#define HTSC_GRPC_LB_TYPE_WRR "weight_round_robin"
#define HTSC_GRPC_DEFAULT_LB_TYPE HTSC_GRPC_LB_TYPE_RR

#define HTSC_GRPC_LB_MODE_REQUEST "request"
#define HTSC_GRPC_LB_MODE_CONNECT "connection"


#define HTSC_GRPC_CLUSTER_TYPE_FO "failover"
#define HTSC_GRPC_CLUSTER_TYPE_FF "failfast"
#define HTSC_GRPC_CLUSTER_TYPE_FB "failback"
#define HTSC_GRPC_CLUSTER_TYPE_FK "forking"

typedef enum _loadbalance_strategy_t {
		GRPCLB,
		PICK_FIRST,
		ROUND_ROBIN,
		WEIGHT_ROUND_ROBIN
}loadbalance_strategy_t;

typedef enum _cluster_strategy_t {
		FAILOVER,
		FAILFAST,
		FAILBACK,
		FORKING
}cluster_strategy_t;

#define PROVIDER_PROPERTIES_MAX_NUM 50
#define PROTOCOL_NAME_MAX_LEN 20 
#define HOST_MAX_LEN 50
typedef struct _provider_t {
	char protocol[PROTOCOL_NAME_MAX_LEN];
	char *username;
	char *password;
	char host[HOST_MAX_LEN];
	int port;
	char *version;
	char *group;
	int default_timeout;
	int default_reties;
	int default_connections;
	int default_requests;
	bool access_protected;
	loadbalance_strategy_t default_loadbalance;
	bool default_async;
	char *token;
	bool deprecated;
	bool dynamic;
	bool accesslog;
	char *owner;
	int weight;
	cluster_strategy_t default_cluster;
	char *application;
	char *application_version;
	char *organization;
	char *environment;
	char *module;
	char *module_version;
	bool anyhost;
	char *sInterface;
	char *methods;
	long pid;
	char side[20];
	int64_t timestamp;
	char *grpc;
	char *dubbo;
	int flag;
	void *ext_data;
}provider_t;

#define HTSC_GRPC_PROVIDER_FLAG_IN_BLKLIST 0
#define HTSC_GRPC_PROVIDER_FLAG_LIVE 1     //该provider是否有效（例如不在黑名单中等），即不需要释放空间
#define HTSC_GRPC_PROVIDER_FLAG_CALL_FAIlOVER 2
#define HTSC_GRPC_PROVIDER_FLAG_NOT_ACCESSED_BY_OLD_CLIENT 3  //新服务上线，新服务不被旧客户端调用


#ifdef __cplusplus
}
#endif

#endif // !HTSC_TYPES_H
